<?php
/**
 * Created by PhpStorm.
 * User: ari
 * Date: 10/18/14
 * Time: 9:26 AM
 */
namespace BC\Games\Holdem\Hands;

use BC\Games\Holdem\Cards;
use BC\Games\Holdem\Deck;
use CPath\UnitTest\ITestable;
use CPath\UnitTest\IUnitTestRequest;

class RoyalFlushHand extends StraightFlushHand implements ITestable
{
	const RANK = 9000;

	/**
	 * Return name of this hand
	 * @return String
	 */
	function getName() {
		return "Royal Flush";
	}

	// Static

	/**
	 * Tests a poker hand to see if it matches an array of cards
	 * @param array $cards
	 * @param IPokerHand[] $Matches
	 * @throws \InvalidArgumentException
	 * @return bool true if the set of cards matches this poker hand
	 */
	static function match(Array $cards, &$Matches = array()) {
		throw new \InvalidArgumentException("Royal Flush may not be matched directly");
	}

	/**
	 * Perform a unit test
	 * @param IUnitTestRequest $Test the unit test request inst for this test session
	 * @return void
	 * @test --disable 0
	 * Note: Use doctag 'test' with '--disable 1' to have this ITestable class skipped during a build
	 */
	static function handleStaticUnitTest(IUnitTestRequest $Test) {
		$Deck = new Deck();
		$Deck->replay(Cards::ACE | Cards::HEARTS, 'player1');
		$Deck->replay(Cards::JACK | Cards::HEARTS, 'player1');
		$Deck->replay(Cards::TEN | Cards::HEARTS, 'board');
		$Deck->replay(Cards::QUEEN | Cards::HEARTS, 'board');
		$Deck->replay(Cards::TWO | Cards::HEARTS, 'board');
		$Deck->replay(Cards::TWO | Cards::CLUBS, 'board');
		$Deck->replay(Cards::KING | Cards::HEARTS, 'board');

		$cards = $Deck->getDrawnCards('player1', 'board');
		if (!StraightFlushHand::match($cards, $Hands))
			$Test->fail("Royal Flush not matched to cards: " . Cards::printCards($cards));

		$Test->assert($Hands[0] instanceof RoyalFlushHand, "Royal Flush did not match: " . Cards::printCards($cards));

		$Test->log("Matched Royal Flush to " . $Hands[0] . ' from ' . Cards::printCards($cards), $Test::VERBOSE);
	}
}